package com.kmzx.one.project.controller;

import com.kmzx.one.common.annotation.ApiAuth;
import com.kmzx.one.project.net.BaseResult;
import com.kmzx.one.project.others.common.IdAndKinds;
import com.kmzx.one.project.others.dto.GreatBrand;
import com.kmzx.one.project.others.dto.GreatBrandMain;
import com.kmzx.one.project.others.dto.ProdCateInfo;
import com.kmzx.one.project.others.dto.ProdOutInfo;
import com.kmzx.one.project.service.BrandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "快美甄选_[ 商品品牌_接口 ]")
@RestController
public class BrandController extends BaseController {


    @Autowired
    BrandService brandService;

    @ApiAuth
    @ApiOperation(value = "1.精选品牌", notes = "精选品牌",position = -1)
    @GetMapping(value = "brand/home")
    public BaseResult pickedBrand(String userId) {
        try {
            List<GreatBrand> detail = brandService.findGreatBrand(userId);
            BaseResult success = BaseResult.Builder.SUCC().initSuccData(detail);
            return success;
        } catch (Exception e) {
            return handleException(e);
        }
    }

    @ApiOperation(value = "2.品牌区，信息", notes = "品牌区，信息")
    @GetMapping(value = "brand/main")
    public BaseResult pickedBrandMain(String brandId, String userId) {
        try {
            GreatBrandMain detail = brandService.findBrandMainInfo(brandId, userId);
            BaseResult success = BaseResult.Builder.SUCC().initSuccData(detail);
            return success;
        } catch (Exception e) {
            return handleException(e);
        }
    }

    @ApiOperation(value = "3.商品分类", notes = "品牌区，商品分类")
    @GetMapping(value = "brand/cate")
    public BaseResult pickedBrandCate(String userId) {
        try {
            List<ProdCateInfo> detail = brandService.findProdCateInfo(userId);
            BaseResult success = BaseResult.Builder.SUCC().initSuccData(detail);
            return success;
        } catch (Exception e) {
            return handleException(e);
        }
    }

    @ApiOperation(value = "4.商品分类_分类细节", notes = "品牌区，商品分类_分类细节")
    @GetMapping(value = "brand/cateInfo")
    public BaseResult pickedBrandCateDetail(String userId, String cateId) {
        try {
            List<ProdCateInfo> detail = brandService.findProdOfCateInfo(userId, Integer.valueOf(cateId));
            BaseResult success = BaseResult.Builder.SUCC().initSuccData(detail);
            return success;
        } catch (Exception e) {
            return handleException(e);
        }
    }


    @ApiOperation(value = "5.分类下的商品", notes = "5.分类下的商品")
    @GetMapping(value = "brand/prodByCate")
    public BaseResult pickedProdsByCateId(String userId, String cateId) {
        try {
            List<ProdOutInfo> detail = brandService.findProdByCateId(userId, Integer.valueOf(cateId));
            BaseResult success = BaseResult.Builder.SUCC().initSuccData(detail);
            return success;
        } catch (Exception e) {
            return handleException(e);
        }
    }

    @ApiOperation(value = "6.选择分类/品牌", notes = "6.选择分类/品牌",position = -1)
    @GetMapping(value = "brand/which")
    public BaseResult pickedBrandWhich() {
        try {
            List<IdAndKinds> detail = brandService.findSwitchCate();
            BaseResult success = BaseResult.Builder.SUCC().initSuccData(detail);
            return success;
        } catch (Exception e) {
            return handleException(e);
        }
    }



}
